export default {
    data() {
        return {
            restaurants: []
        }
    },
    methods: {
        querySearch(queryString, cb) {
            var restaurants = this.restaurants;
            var results = queryString ?
                restaurants.filter(this.createFilter(queryString)) :
                restaurants;
            // 调用 callback 返回建议列表的数据
            cb(results);
        },
        createFilter(queryString) {
            return restaurant => {
                return (
                    restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) ===
                    0
                );
            };
        },
        loadAll() {
            return [{
                value: "三全鲜食（北新泾店）",
                address: "长宁区新渔路144号"
            }];
        }
    },

    mounted() {
        this.restaurants = this.loadAll();
    }
}